<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />

</head>

<body>
  <div style="margin-top: 400px;margin-left: 150px;" onclick="login_out();"">退出</div>
</body>
<script type="text/javascript" src="./script/api.js"></script>
<script type="text/javascript" src="./script/common.js"></script>
<script type="text/javascript" src="./script/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
apiready = function() {
  logo();
};

function logo(){
  if(localStorage.user_id == "" || localStorage.user_id == undefined){
    api.openFrame({
        name: 'login',
        url: 'widget://html/login.html',
        rect: {
            x: 0,
            y: 0,
            w: api.winWidth,
            h: api.winHeight
        },
        bounces:false
    });
  }
}

function login_out () {
    api.confirm({
        title: '温馨提示',
        msg: '确认退出吗亲？',
        buttons: ['确定', '取消']
    }, function (ret, err) {
        if (ret) {
            var index = ret.buttonIndex;
            if (index == 1) {
                ajax('/login_out_user',{},function(ret){
                    localStorage.user_id = "";
                    toast("登出成功！");
                    api.rebootApp();
                })
            }
        } else {
            toast(JSON.stringify(err));
        }
    });
}

</script>

</html>
